<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://sargue.net/jsptags/time" prefix="javatime" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>收货地址</title>
   <%@include file="../common/header.jsp" %>
    <jsp:include page="../../common/layer.jsp"></jsp:include>
    <jsp:include page="../../common/mydate.jsp"></jsp:include>
      <script type="text/javascript">
    	
    	function deleteOne(id){
    		if(confirm("是否删除此条数据")){
    			var url="${pathUrl}/home/center/deleteAddress";
    			$.post(url,{id:id},function(resultObj){
    				if(resultObj.status==1){
    					alert("删除成功！");
    					ajaxData();
    				}else{
    					alert("删除失败！");
    				}
    			});
    		}
    	}
  
    </script>
</head>
<body>

<%@include file="../common/top.jsp" %>
<div class="section clearfix" style="margin-top: 10px;">
    <!--页面左边-->
      	<%@include file="left.jsp" %>
    <!--/页面左边-->

<form id="mainForm" action="${pathUrl }/home/center/addressIndexList" method="post">
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">

            <div class="sub-tit " style="margin: 0px;">
                <a class="add" href="${pathUrl }/home/center/editorAddress"><i class="iconfont icon-reply"></i>新增地址</a>
                <ul>
                    <li class="selected">
                        <a href="javascript:;">收货地址</a>
                    </li>
                </ul>
            </div>

            <div id="address-Main">
                <table width="100%" border="0" cellspacing="0" cellpadding="0"
                       class="ftable">
                    <tbody>
                    <tr>
                        <th align="left">收货地址</th>
                        <th width="18%" align="left">手机</th>
                        <th width="20%" align="left">邮箱</th>
                        <th width="100">操作</th>
                    </tr>
                    <c:choose>
                        <c:when test="${addressList.size()>0 }">
                            <c:forEach var="vo" items="${addressList }">
                                <tr>
                                    <td>${vo.userName }${vo.province }${vo.area }${vo.city }</td>
                                    <td>${vo.phone}</td>
                                    <td>${vo.email }</td>
                                    <td align="center">
                                        <a href="${pathUrl }/home/center/editorAddress?id=${vo.id}">编辑</a>
                                        | <a href="javascript:;" onclick="deleteOne(${vo.id})">删除</a></td>
                                </tr>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                            <tr>
                                <td colspan="4">暂无数据</td>
                            </tr>
                        </c:otherwise>
                    </c:choose>
                    </tbody>
                </table>

                <input type="hidden" id="pageNum" name="pageNum" value="${pageNum }" />
                <input type="hidden" id="pages" name="pages" value="${pages }" />
                <input type="hidden" id="total" name="total" value="${total }" />
                <input type="hidden" id="pageSize" name="pageSize" value="${pageSize }" />
            </div>
             
	         <div id="pager">

             </div>
        </div>
    </div>
    

    <!--/页面左边-->
 </form>

</div>
<jsp:include page="../../common/laypage.jsp"></jsp:include>
  <script type="text/javascript">
  	$(function(){

  	});

    function deleteOne(id){
        ydlConfrim("你是否删除选择的数据？",function(){
            var url="${pathUrl}/home/center/deleteAddress";
            $.post(url,{id:id},function(result){
                if(result.status == 1){
                    layer.alert('id为'+id+'的数据删除成功', {icon: 1}, function () {
                        window.location.href="${pathUrl}/home/center/addressIndex";
                    });
                }

            });
        });
    }

  </script>
</body>
</html>